<template>
  <div id="app">
    <el-table v-loading="listLoading"
              :data="result.list"
              border
              :header-cell-style="headClass"
              :cell-style="rowClass"
              style="width: 100%">
      <el-table-column
          prop="jobName"
          label="工作名称"
          width="180">
      </el-table-column>
      <el-table-column
          prop="companyName"
          label="企业名称"
          width="180">
      </el-table-column>
      <el-table-column
          prop="seekerName"
          label="求职者名称"
          width="180">
      </el-table-column>
      <el-table-column
          prop="message"
          label="招呼语"
          width="250">
      </el-table-column>
      <el-table-column
          prop="createdTime"
          label="创建时间"
          width="180">
        <template slot-scope="scope">
          <span>{{ dateFormat(scope.row.createdTime) }}<br></span>
        </template>
      </el-table-column>
      <el-table-column
          prop="auditStatus"
          label="处理结果"
          width="180">
        <template slot-scope="scope">
          <div v-if="scope.row.auditStatus===0">
            <span>未处理</span>
          </div>
          <div v-if="scope.row.auditStatus===1">
            <span>处理中</span>
          </div>
          <div v-if="scope.row.auditStatus===2">
            <span>不合适</span>
          </div>
          <div v-if="scope.row.auditStatus===3">
            <span>人才库</span>
          </div>
          <div v-if="scope.row.auditStatus===4">
            <span>合适</span>
          </div>
        </template>
      </el-table-column>
    </el-table>

    <el-footer style="text-align: left;">
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryParam.pageNum"
          :page-sizes="[10,20,30,40,50,100,200,500,1000]"
          :page-size="queryParam.pageSize"
          :layout="queryParam.isCount ? 'total, sizes, prev, pager, next, jumper' : 'sizes, prev, next'"
          :total="result.totalNum">
      </el-pagination>
    </el-footer>
  </div>
</template>

<script>


import jwtUtil from "jwt-decode";
import {getReadDeliveries} from "@/api";

export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: "seeDeliveries",
  data() {
    return {
      user: {
        userId: '',
        objectId: '',
        userType: ''
      },
      listLoading: false,
      queryParam: {
        pageNum: 1,
        pageSize: 10,
        isCount: true,
        seekerId: ''
      },
      result: {
        list: [],
        totalNum: -1
      }
    }

  },
  methods: {
    headClass() {
      return "text-align:center"
    },
    rowClass() {
      return "text-align:center"
    },
    handleSizeChange(val) {
      this.queryParam.pageSize = val
      this.myList()
    },
    handleCurrentChange(val) {
      this.queryParam.pageNum = val
      this.myList()
    },
    dateFormat(it) {
      let date = new Date(it * 1000)
      return (
          date.getFullYear() +
          '年' +
          (date.getMonth() + 1) +
          '月' +
          date.getDate() +
          '日'
      );
    },
    //方法
    myList() {
      this.listLoading = true
      this.queryParam.seekerId = this.user.objectId
      getReadDeliveries(this.queryParam).then(res => {
        this.result.list = res.data.list
        this.result.totalNum = res.data.totalNum
        this.listLoading = false
      })
    }
  },
  created() {
    this.user = jwtUtil(window.localStorage.getItem('Token'))
    this.myList()
  }
}
</script>

<style scoped>

</style>